import axios from '@/libs/axios1.js'
import baseUrl from './index'
let jsonHeaders = { 'content-type': 'application/json;charset=UTF-8' }
let guide = '/self-study/guide'
// 指导书列表
export const getGuideData = (params) => {
    return axios({
        url: `${guide}/expGuide/page`,
        method: 'get',
        params: params,
        headers: jsonHeaders,
    })
}
// 导出指导书
export const exportGuide = (id) => {
    return axios({
        url: `${guide}/expGuideSection/list?guidbookid=${id}`,
        method: 'get',
        headers: jsonHeaders,
    })
}
// 创建
export const creatGuide = (data) => {
    return axios({
        url: `${guide}/expGuide`,
        method: 'post',
        data: JSON.stringify(data),
        headers: jsonHeaders,
    })
}
// 修改
export const modifyGuide = (id, data) => {
    return axios({
        url: `${guide}/expGuide/${id}`,
        method: 'put',
        data: JSON.stringify(data),
        headers: jsonHeaders,
    })
}

// 删除
export const delGuide = (id) => {
    return axios({
        url: `${guide}/expGuide/${id}`,
        method: 'delete',
        headers: jsonHeaders,
    })
}
// 段落列表
export const sectionList = (id) => {
    return axios({
        url: `${guide}/expGuideSection/list?guidbookid=${id}`,
        method: 'get',
        headers: jsonHeaders,
    })
}
//段落列表 -- 新(权限控制不同,用于课件详情指导书查询)
export const sectionList_new = (ecId, id) => {
    return axios({
        url: `${guide}/expGuideSection/${ecId}/list?guidbookid=${id}`,
        method: 'get',
        headers: jsonHeaders,
    })
}
// 图片列表
export const imgList = (params) => {
    return axios({
        url: `${baseUrl}/ftp/filerecord/page`,
        method: 'get',
        params: params,
        headers: jsonHeaders,
    })
}
// 新建段落
export const creatSection = (data) => {
    return axios({
        url: `${guide}/expGuideSection`,
        method: 'post',
        data: JSON.stringify(data),
        headers: jsonHeaders,
    })
}
// 修改段落
export const modifySection = (data, id) => {
    return axios({
        url: `${guide}/expGuideSection/${id}`,
        method: 'put',
        data: JSON.stringify(data),
        headers: jsonHeaders,
    })
}
// 获取指导书信息
export const getGuideInfoByID = (id) => {
    return axios({
        url: `${guide}/expGuide/${id}`,
        method: 'get',
        headers: jsonHeaders,
    })
}

//获取课件指导书信息(新-权限控制不同,用于修改课件中查询)
export const getGuideInfoByID_new = (ecId, guideId) => {
    return axios({
        url: `${guide}/expGuide/${ecId}/${guideId}`,
        method: 'get',
        headers: jsonHeaders,
    })
}
// 删除段落
export const delSection = (id) => {
    return axios({
        url: `${guide}/expGuideSection/${id}`,
        method: 'delete',
        headers: jsonHeaders,
    })
}

//批量绑定课件指导书和习题
export const addSectionQuestion = (guideId, sectionId, data) => {
    return axios({
        url: `${guide}/expQuestion/batchSave/${guideId}/${sectionId}`,
        method: 'post',
        data: data,
        headers: jsonHeaders,
    })
}

//根据段落id查询题目列表
export const querySectionQuestion = sectionId => {
    return axios({
        url: `${guide}/expQuestion/queryGuideQuestionsBySectionId/${sectionId}`,
        method: 'get',
        params: {},
        headers: jsonHeaders,
    })
}

//删除段落题目
export const delSectionQuestion = (id) => {
    return axios({
        url: `${guide}/expQuestion/delete/${id}`,
        method: 'post',
        headers: jsonHeaders,
    })
}
export const donwLoadMdFile = (path) => {
    return axios({
        url: `/minio/downloadByte`,
        //url: `${baseUrl}/minio/download/MINIO-7e-4395-4c72-a637-b586fcd2604e`,
        //url: `../static/README.md`,
        params: path,
        method: 'get',
        headers: jsonHeaders,
        timeout:0
    })
}
//上传图片
export const uploadImages = data => {
    return axios({
        url: `/minio/upload/permanent?visibility=company&type=images&bucket=images`,
        method: 'post',
        data,
        headers: jsonHeaders,
        timeout:0
    })
}